
from django.db import models
# 封装常用字段 拿来用就行


class DateTimeModelMixin(models.Model):
    created_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    # 防止映射迁移 生成表
    # 成为其他模型的继承操作
    class Meta:
        abstract = True  # 抽象类


class IsDeleteModelMixin(models.Model):
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除标记')

    def delete(self, using=None, keep_parents=False):
        self.is_delete = True
        self.save()

    class Meta:
        abstract = True


class ModelMixin(DateTimeModelMixin, IsDeleteModelMixin):
    class Meta:
        abstract = True